{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# PREPARE DATA FOR FRAME EXTRACTION"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "\n",
    "def process_json_files(root_folder):\n",
    "    \"\"\"\n",
    "    Scans root_folder for JSON files containing annotations, aggregates them by clip_uid into dict mapping clip to frame\n",
    "    and to annot_uid\n",
    "\n",
    "    Args:\n",
    "    - root_folder (str): Path to the annots folder\n",
    "\n",
    "    Returns:\n",
    "    - dict: A dictionary mapping clip UIDs to their frames' annotations, categorized by frame number and type ('pre', 'pnr', 'post'), \n",
    "      alongside the annot_uid.\n",
    "    \"\"\"\n",
    "    result_dict = {}\n",
    "    for subdir, _, files in os.walk(root_folder):\n",
    "        for file in files:\n",
    "            if file.endswith(\".json\"):\n",
    "                annot_uid = os.path.basename(subdir)  # assuming annot_uid is the subfolder name\n",
    "                file_path = os.path.join(subdir, file)\n",
    "                \n",
    "                with open(file_path, 'r') as json_file:\n",
    "                    data = json.load(json_file)\n",
    "                    \n",
    "                    clip_uid = data.get('clip_uid')\n",
    "                    pre_frame_number = data.get('pre_frame')['clip_frame_number']\n",
    "                    pnr_frame_number = data.get('pnr_frame')['clip_frame_number']\n",
    "                    post_frame_number = data.get('post_frame')['clip_frame_number']\n",
    "                    \n",
    "                    if clip_uid:\n",
    "                        if clip_uid not in result_dict:\n",
    "                            result_dict[clip_uid] = {}\n",
    "                        \n",
    "                        frames = [(pre_frame_number, 'pre'), (pnr_frame_number, 'pnr'), (post_frame_number, 'post')]\n",
    "                        \n",
    "                        for frame_number, frame_type in frames:\n",
    "                            if frame_number:\n",
    "                                if frame_number not in result_dict[clip_uid]:\n",
    "                                    result_dict[clip_uid][frame_number] = []\n",
    "                                \n",
    "                                result_dict[clip_uid][frame_number].append((frame_type, annot_uid))\n",
    "                            \n",
    "    return result_dict\n",
    "\n",
    "# Modify this to the path of your \"annotations_all\" folder\n",
    "root_folder = \"annotations_all\"\n",
    "processed_data = process_json_files(root_folder)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{48: [('pre',\n",
       "   '2ce11f8f93edca540164c11adcba4bcce0fdebf378af50757a688f0abc13e0cc')],\n",
       " 62: [('pnr',\n",
       "   '2ce11f8f93edca540164c11adcba4bcce0fdebf378af50757a688f0abc13e0cc')],\n",
       " 69: [('post',\n",
       "   '2ce11f8f93edca540164c11adcba4bcce0fdebf378af50757a688f0abc13e0cc')],\n",
       " 72: [('pre',\n",
       "   '77db171652757f04902cbe8aa2422a97c62f3ec1ee0799bb9b021877c109eaed')],\n",
       " 75: [('pnr',\n",
       "   '77db171652757f04902cbe8aa2422a97c62f3ec1ee0799bb9b021877c109eaed')],\n",
       " 102: [('post',\n",
       "   '77db171652757f04902cbe8aa2422a97c62f3ec1ee0799bb9b021877c109eaed')],\n",
       " 136: [('pre',\n",
       "   '50432b97708db6fa1d74b9a9d873756402ac489d911364339a2741082011ac87')],\n",
       " 141: [('pnr',\n",
       "   '50432b97708db6fa1d74b9a9d873756402ac489d911364339a2741082011ac87')],\n",
       " 161: [('post',\n",
       "   '50432b97708db6fa1d74b9a9d873756402ac489d911364339a2741082011ac87')],\n",
       " 164: [('pre',\n",
       "   'db01246efd46f56d4718037a02a63f64b3c05b52d03ddffde3c8cc9bbace0576')],\n",
       " 167: [('pnr',\n",
       "   'db01246efd46f56d4718037a02a63f64b3c05b52d03ddffde3c8cc9bbace0576')],\n",
       " 185: [('post',\n",
       "   'db01246efd46f56d4718037a02a63f64b3c05b52d03ddffde3c8cc9bbace0576')],\n",
       " 960: [('pre',\n",
       "   '941e4f2380fe9fc9658c71e9a1322aea3fa7ec1b549e3dad47d2be90412d8c9b')],\n",
       " 977: [('pnr',\n",
       "   '941e4f2380fe9fc9658c71e9a1322aea3fa7ec1b549e3dad47d2be90412d8c9b')],\n",
       " 1047: [('post',\n",
       "   '941e4f2380fe9fc9658c71e9a1322aea3fa7ec1b549e3dad47d2be90412d8c9b')],\n",
       " 1005: [('pre',\n",
       "   '2cfe055e1f8a2018f2f4807dfeb2c0cc10136e1835c9e0df7a428867fb756760')],\n",
       " 1021: [('pnr',\n",
       "   '2cfe055e1f8a2018f2f4807dfeb2c0cc10136e1835c9e0df7a428867fb756760')],\n",
       " 1060: [('post',\n",
       "   '2cfe055e1f8a2018f2f4807dfeb2c0cc10136e1835c9e0df7a428867fb756760')],\n",
       " 1162: [('pre',\n",
       "   'a8054cfffc8748dafcc2c38bb7436ffc5605795888fb253f17aec79186db9267')],\n",
       " 1173: [('pnr',\n",
       "   'a8054cfffc8748dafcc2c38bb7436ffc5605795888fb253f17aec79186db9267')],\n",
       " 1187: [('post',\n",
       "   'a8054cfffc8748dafcc2c38bb7436ffc5605795888fb253f17aec79186db9267')],\n",
       " 1243: [('pre',\n",
       "   '0d299d0d30579d16bc38521104d7b201b1b67b94fe89b8f736b9d83b140bf98f')],\n",
       " 1258: [('pnr',\n",
       "   '0d299d0d30579d16bc38521104d7b201b1b67b94fe89b8f736b9d83b140bf98f')],\n",
       " 1372: [('post',\n",
       "   '0d299d0d30579d16bc38521104d7b201b1b67b94fe89b8f736b9d83b140bf98f')],\n",
       " 1248: [('pre',\n",
       "   'ff484ebb97a062d5e68158e560590e8fa1c02d1b444481bf7551cab29f8c59fe')],\n",
       " 1324: [('pnr',\n",
       "   'ff484ebb97a062d5e68158e560590e8fa1c02d1b444481bf7551cab29f8c59fe')],\n",
       " 1399: [('post',\n",
       "   'ff484ebb97a062d5e68158e560590e8fa1c02d1b444481bf7551cab29f8c59fe')],\n",
       " 1316: [('pre',\n",
       "   'e470eba5232178e3d7a658fffd7f262608f01f6215e18a7238ea3420bd53a274')],\n",
       " 1392: [('pnr',\n",
       "   'e470eba5232178e3d7a658fffd7f262608f01f6215e18a7238ea3420bd53a274')],\n",
       " 1496: [('post',\n",
       "   'e470eba5232178e3d7a658fffd7f262608f01f6215e18a7238ea3420bd53a274')],\n",
       " 1567: [('pre',\n",
       "   '33ed14e8b6f9f0852bb1562652826a532a849e70377020f4c5c742b10acd86aa')],\n",
       " 1642: [('pnr',\n",
       "   '33ed14e8b6f9f0852bb1562652826a532a849e70377020f4c5c742b10acd86aa')],\n",
       " 1717: [('post',\n",
       "   '33ed14e8b6f9f0852bb1562652826a532a849e70377020f4c5c742b10acd86aa')],\n",
       " 1588: [('pre',\n",
       "   '2a3483dd4b708dd065489c1813b728c9cc115cbc35a79f43c4053f779e8625b9')],\n",
       " 1666: [('pnr',\n",
       "   '2a3483dd4b708dd065489c1813b728c9cc115cbc35a79f43c4053f779e8625b9')],\n",
       " 1738: [('post',\n",
       "   '2a3483dd4b708dd065489c1813b728c9cc115cbc35a79f43c4053f779e8625b9')],\n",
       " 1606: [('pre',\n",
       "   '6b3cb49be1ca3a6c53dadbfe183fd3a2514a14ec66836a7ce4a1868bcea5cd70')],\n",
       " 1680: [('pnr',\n",
       "   '6b3cb49be1ca3a6c53dadbfe183fd3a2514a14ec66836a7ce4a1868bcea5cd70')],\n",
       " 1756: [('post',\n",
       "   '6b3cb49be1ca3a6c53dadbfe183fd3a2514a14ec66836a7ce4a1868bcea5cd70')],\n",
       " 1798: [('pre',\n",
       "   '03802e26f52dffbdacb136a861e097fdcd0c9e07b957640caaca1963a1148c2e')],\n",
       " 1843: [('pnr',\n",
       "   '03802e26f52dffbdacb136a861e097fdcd0c9e07b957640caaca1963a1148c2e')],\n",
       " 1904: [('post',\n",
       "   '03802e26f52dffbdacb136a861e097fdcd0c9e07b957640caaca1963a1148c2e')],\n",
       " 2743: [('pre',\n",
       "   'da83a9bbaf4a291058cbf1e77341b799eaef0d854a1b591b3d64cb2be1f85e9d')],\n",
       " 2749: [('pnr',\n",
       "   'da83a9bbaf4a291058cbf1e77341b799eaef0d854a1b591b3d64cb2be1f85e9d')],\n",
       " 2771: [('post',\n",
       "   'da83a9bbaf4a291058cbf1e77341b799eaef0d854a1b591b3d64cb2be1f85e9d')],\n",
       " 2783: [('pre',\n",
       "   '6dc4acc44eb53a734a7c5acade6058202f9e526305218a3c954931d3a040689d')],\n",
       " 2789: [('pnr',\n",
       "   '6dc4acc44eb53a734a7c5acade6058202f9e526305218a3c954931d3a040689d')],\n",
       " 2873: [('post',\n",
       "   '6dc4acc44eb53a734a7c5acade6058202f9e526305218a3c954931d3a040689d'),\n",
       "  ('pre', '4490780ab36d4304f97145173900ad295ee9d2dfb4b7e7706c27ad54a4114ac1')],\n",
       " 2876: [('pnr',\n",
       "   '4490780ab36d4304f97145173900ad295ee9d2dfb4b7e7706c27ad54a4114ac1')],\n",
       " 2878: [('post',\n",
       "   '4490780ab36d4304f97145173900ad295ee9d2dfb4b7e7706c27ad54a4114ac1')],\n",
       " 2913: [('pre',\n",
       "   '94ab2ef6eb7b32fffe31e53df400dc991d272cf371423174374c882a2ef6ba6d')],\n",
       " 2915: [('pnr',\n",
       "   '94ab2ef6eb7b32fffe31e53df400dc991d272cf371423174374c882a2ef6ba6d')],\n",
       " 2992: [('post',\n",
       "   '94ab2ef6eb7b32fffe31e53df400dc991d272cf371423174374c882a2ef6ba6d')],\n",
       " 2978: [('pre',\n",
       "   '3652dff608b76b3b197a2c7fd0b7acacb9ce3ccc26b0805a122a66f5bd126c98')],\n",
       " 2983: [('pnr',\n",
       "   '3652dff608b76b3b197a2c7fd0b7acacb9ce3ccc26b0805a122a66f5bd126c98')],\n",
       " 3130: [('post',\n",
       "   '3652dff608b76b3b197a2c7fd0b7acacb9ce3ccc26b0805a122a66f5bd126c98')],\n",
       " 3005: [('pre',\n",
       "   'f3df1911832c324c8bc35586fe2dd77e2fc071b472e42ac47f3f7c926e83b1f2')],\n",
       " 3011: [('pnr',\n",
       "   'f3df1911832c324c8bc35586fe2dd77e2fc071b472e42ac47f3f7c926e83b1f2')],\n",
       " 3124: [('post',\n",
       "   'f3df1911832c324c8bc35586fe2dd77e2fc071b472e42ac47f3f7c926e83b1f2')],\n",
       " 3122: [('pre',\n",
       "   '048de16984118093ecf33117058f3ce7075c899929b92ac71343e2c2e1e22e75')],\n",
       " 3135: [('pnr',\n",
       "   '048de16984118093ecf33117058f3ce7075c899929b92ac71343e2c2e1e22e75')],\n",
       " 3146: [('post',\n",
       "   '048de16984118093ecf33117058f3ce7075c899929b92ac71343e2c2e1e22e75')],\n",
       " 3263: [('pre',\n",
       "   '2a476a3fe155cfec87065fc5a1206ade36690a90458e957946d9160871f33544')],\n",
       " 3285: [('pnr',\n",
       "   '2a476a3fe155cfec87065fc5a1206ade36690a90458e957946d9160871f33544')],\n",
       " 3392: [('post',\n",
       "   '2a476a3fe155cfec87065fc5a1206ade36690a90458e957946d9160871f33544')],\n",
       " 3387: [('pre',\n",
       "   'b2e9d4d1c4ac99dde4ba567fd9cb1f896ea210af0715afad8e00e40b346dac57')],\n",
       " 3393: [('pnr',\n",
       "   'b2e9d4d1c4ac99dde4ba567fd9cb1f896ea210af0715afad8e00e40b346dac57')],\n",
       " 3395: [('post',\n",
       "   'b2e9d4d1c4ac99dde4ba567fd9cb1f896ea210af0715afad8e00e40b346dac57')],\n",
       " 3749: [('pre',\n",
       "   'a4812e8a6276efb2b73b3c9996694b7bafae75032442b950e82ea0123967ff21')],\n",
       " 3769: [('pnr',\n",
       "   'a4812e8a6276efb2b73b3c9996694b7bafae75032442b950e82ea0123967ff21')],\n",
       " 3839: [('post',\n",
       "   'a4812e8a6276efb2b73b3c9996694b7bafae75032442b950e82ea0123967ff21')],\n",
       " 3817: [('pre',\n",
       "   '56249425c4f8c0267abb495db431e504715e50a8f7eccbf446117dc11242ab8a')],\n",
       " 3829: [('pnr',\n",
       "   '56249425c4f8c0267abb495db431e504715e50a8f7eccbf446117dc11242ab8a')],\n",
       " 3928: [('post',\n",
       "   '56249425c4f8c0267abb495db431e504715e50a8f7eccbf446117dc11242ab8a')],\n",
       " 3950: [('pre',\n",
       "   '888d6821f2d6d8d57027b839bb0ce570be5cb5786302a82a8f36bca1e8bb601d')],\n",
       " 3969: [('pnr',\n",
       "   '888d6821f2d6d8d57027b839bb0ce570be5cb5786302a82a8f36bca1e8bb601d')],\n",
       " 3988: [('post',\n",
       "   '888d6821f2d6d8d57027b839bb0ce570be5cb5786302a82a8f36bca1e8bb601d')],\n",
       " 4089: [('pre',\n",
       "   '357e45fc5d04b6f560f53fc81f30c86616f42990b21bc2a09dc7c3895b627bf1')],\n",
       " 4101: [('pnr',\n",
       "   '357e45fc5d04b6f560f53fc81f30c86616f42990b21bc2a09dc7c3895b627bf1')],\n",
       " 4114: [('post',\n",
       "   '357e45fc5d04b6f560f53fc81f30c86616f42990b21bc2a09dc7c3895b627bf1')],\n",
       " 4208: [('pre',\n",
       "   '17bf1f27cd992220df70e94be7e78a861701f26f666450d3742b7ef9ebb3ee63')],\n",
       " 4227: [('pnr',\n",
       "   '17bf1f27cd992220df70e94be7e78a861701f26f666450d3742b7ef9ebb3ee63')],\n",
       " 4251: [('post',\n",
       "   '17bf1f27cd992220df70e94be7e78a861701f26f666450d3742b7ef9ebb3ee63')],\n",
       " 4329: [('pre',\n",
       "   'c87e8eb6bff9da2d40de326565e8d9847c7ba19f8515dc7e48562d54294f4a9f')],\n",
       " 4348: [('pnr',\n",
       "   'c87e8eb6bff9da2d40de326565e8d9847c7ba19f8515dc7e48562d54294f4a9f')],\n",
       " 4366: [('post',\n",
       "   'c87e8eb6bff9da2d40de326565e8d9847c7ba19f8515dc7e48562d54294f4a9f')],\n",
       " 4860: [('pre',\n",
       "   '27d2c0585b280112fd877372a806c34e5b98a58222d65a4aff1bb2af796f74a2')],\n",
       " 4868: [('pnr',\n",
       "   '27d2c0585b280112fd877372a806c34e5b98a58222d65a4aff1bb2af796f74a2')],\n",
       " 4911: [('post',\n",
       "   '27d2c0585b280112fd877372a806c34e5b98a58222d65a4aff1bb2af796f74a2')],\n",
       " 4994: [('pre',\n",
       "   '03861c9a9e333be6b04cd7f3cd2fe57e6795817a55056f0c1f0ee8699327b622')],\n",
       " 5002: [('pnr',\n",
       "   '03861c9a9e333be6b04cd7f3cd2fe57e6795817a55056f0c1f0ee8699327b622')],\n",
       " 5039: [('post',\n",
       "   '03861c9a9e333be6b04cd7f3cd2fe57e6795817a55056f0c1f0ee8699327b622')],\n",
       " 5046: [('pre',\n",
       "   'f7387204a82a83f5a742f4ca8e7e60a2d2b8d9eb876bc9dd78b4c41fed7b5884')],\n",
       " 5055: [('pnr',\n",
       "   'f7387204a82a83f5a742f4ca8e7e60a2d2b8d9eb876bc9dd78b4c41fed7b5884')],\n",
       " 5161: [('post',\n",
       "   'f7387204a82a83f5a742f4ca8e7e60a2d2b8d9eb876bc9dd78b4c41fed7b5884')],\n",
       " 5623: [('pre',\n",
       "   '8495b511999b8134249f9dc8cc91dcc1f5d7318181ef4a35c9d43a67f1c3e449')],\n",
       " 5626: [('pnr',\n",
       "   '8495b511999b8134249f9dc8cc91dcc1f5d7318181ef4a35c9d43a67f1c3e449')],\n",
       " 5630: [('post',\n",
       "   '8495b511999b8134249f9dc8cc91dcc1f5d7318181ef4a35c9d43a67f1c3e449')],\n",
       " 5717: [('pre',\n",
       "   'f0ab78d8b30ddaec71c6e088c910b2e2240673fb9892a1d3cd9242de5cc2c0b7')],\n",
       " 5730: [('pnr',\n",
       "   'f0ab78d8b30ddaec71c6e088c910b2e2240673fb9892a1d3cd9242de5cc2c0b7')],\n",
       " 5736: [('post',\n",
       "   'f0ab78d8b30ddaec71c6e088c910b2e2240673fb9892a1d3cd9242de5cc2c0b7')],\n",
       " 5818: [('pre',\n",
       "   '67829ca87ca344225a460e287991aff71da99d6759bda4543c85f925d8657d3d')],\n",
       " 5839: [('pnr',\n",
       "   '67829ca87ca344225a460e287991aff71da99d6759bda4543c85f925d8657d3d')],\n",
       " 5859: [('post',\n",
       "   '67829ca87ca344225a460e287991aff71da99d6759bda4543c85f925d8657d3d')],\n",
       " 5892: [('pre',\n",
       "   '864bb0b42f34b26b48ebc8d6e972a7293aef8a6995b1203dea0e2e076e9c7ac3')],\n",
       " 5899: [('pnr',\n",
       "   '864bb0b42f34b26b48ebc8d6e972a7293aef8a6995b1203dea0e2e076e9c7ac3')],\n",
       " 5927: [('post',\n",
       "   '864bb0b42f34b26b48ebc8d6e972a7293aef8a6995b1203dea0e2e076e9c7ac3')],\n",
       " 6067: [('pre',\n",
       "   '51dd43adf93f3caad55ac833d92fd4ade71d7d1ed5a1f9b872e0b4c70eb6a7ef')],\n",
       " 6095: [('pnr',\n",
       "   '51dd43adf93f3caad55ac833d92fd4ade71d7d1ed5a1f9b872e0b4c70eb6a7ef')],\n",
       " 6162: [('post',\n",
       "   '51dd43adf93f3caad55ac833d92fd4ade71d7d1ed5a1f9b872e0b4c70eb6a7ef')],\n",
       " 6135: [('pre',\n",
       "   '1ed750ecfdccc09f85de467eb326381e3ea19f27e6d4daa837e00351f17cd4d6')],\n",
       " 6142: [('pnr',\n",
       "   '1ed750ecfdccc09f85de467eb326381e3ea19f27e6d4daa837e00351f17cd4d6'),\n",
       "  ('pre', '9aa433a6740d410bef8fbb4c25ab458dd2c5df866ef0daa7885e5ef9cb0e48b7')],\n",
       " 6159: [('post',\n",
       "   '1ed750ecfdccc09f85de467eb326381e3ea19f27e6d4daa837e00351f17cd4d6')],\n",
       " 6154: [('pnr',\n",
       "   '9aa433a6740d410bef8fbb4c25ab458dd2c5df866ef0daa7885e5ef9cb0e48b7')],\n",
       " 6168: [('post',\n",
       "   '9aa433a6740d410bef8fbb4c25ab458dd2c5df866ef0daa7885e5ef9cb0e48b7')],\n",
       " 6307: [('pre',\n",
       "   '4a1a26f399e289f873c6858f3ae173fbd74a9f08b6852e5298399f917efa8e09')],\n",
       " 6320: [('pnr',\n",
       "   '4a1a26f399e289f873c6858f3ae173fbd74a9f08b6852e5298399f917efa8e09')],\n",
       " 6421: [('post',\n",
       "   '4a1a26f399e289f873c6858f3ae173fbd74a9f08b6852e5298399f917efa8e09')],\n",
       " 6460: [('pre',\n",
       "   '4ca76f93c40621b7f7b77816ea7b5eb1346b44c2b92fbcb4ad9a3cf022444300')],\n",
       " 6474: [('pnr',\n",
       "   '4ca76f93c40621b7f7b77816ea7b5eb1346b44c2b92fbcb4ad9a3cf022444300')],\n",
       " 6555: [('post',\n",
       "   '4ca76f93c40621b7f7b77816ea7b5eb1346b44c2b92fbcb4ad9a3cf022444300')],\n",
       " 6565: [('pre',\n",
       "   '0c0c3b3160fb2588eff1cbbf0fe565f606de23b20f4ee4c215056aa5b6a11223')],\n",
       " 6591: [('pnr',\n",
       "   '0c0c3b3160fb2588eff1cbbf0fe565f606de23b20f4ee4c215056aa5b6a11223')],\n",
       " 6604: [('post',\n",
       "   '0c0c3b3160fb2588eff1cbbf0fe565f606de23b20f4ee4c215056aa5b6a11223')],\n",
       " 6810: [('pre',\n",
       "   '83ff662172cf641add76887c9f6f880491836b99a4ec03f0b0d5a1240a3e9364')],\n",
       " 6812: [('pnr',\n",
       "   '83ff662172cf641add76887c9f6f880491836b99a4ec03f0b0d5a1240a3e9364')],\n",
       " 6815: [('post',\n",
       "   '83ff662172cf641add76887c9f6f880491836b99a4ec03f0b0d5a1240a3e9364')],\n",
       " 6923: [('pre',\n",
       "   'ec7a42e50e72832c515464331bdce2abe3df749c3a35f206926132a125652863')],\n",
       " 6936: [('pnr',\n",
       "   'ec7a42e50e72832c515464331bdce2abe3df749c3a35f206926132a125652863')],\n",
       " 6951: [('post',\n",
       "   'ec7a42e50e72832c515464331bdce2abe3df749c3a35f206926132a125652863')],\n",
       " 6947: [('pre',\n",
       "   '016e73f3e26d65891b12cdb97a75fec24def071a2ac8e3bb8e3ab0700defd6d9')],\n",
       " 6960: [('pnr',\n",
       "   '016e73f3e26d65891b12cdb97a75fec24def071a2ac8e3bb8e3ab0700defd6d9')],\n",
       " 6979: [('post',\n",
       "   '016e73f3e26d65891b12cdb97a75fec24def071a2ac8e3bb8e3ab0700defd6d9')],\n",
       " 7046: [('pre',\n",
       "   '2ee17ae80bbf62a4f80b3a03bc6d2402d7f049b7dfda737e5a82ce45f70c3f86')],\n",
       " 7057: [('pnr',\n",
       "   '2ee17ae80bbf62a4f80b3a03bc6d2402d7f049b7dfda737e5a82ce45f70c3f86')],\n",
       " 7096: [('post',\n",
       "   '2ee17ae80bbf62a4f80b3a03bc6d2402d7f049b7dfda737e5a82ce45f70c3f86')],\n",
       " 8007: [('pre',\n",
       "   'd07cf67e27f925d0590a70e32ec690b16f0d613e95edf361cd704713b05210cf'),\n",
       "  ('pre', '2569d40588e863bf929a083a5dd2ace8fcff77346978a88fba0d97ad56ff759f')],\n",
       " 8028: [('pnr',\n",
       "   'd07cf67e27f925d0590a70e32ec690b16f0d613e95edf361cd704713b05210cf')],\n",
       " 8091: [('post',\n",
       "   'd07cf67e27f925d0590a70e32ec690b16f0d613e95edf361cd704713b05210cf')],\n",
       " 8053: [('pnr',\n",
       "   '2569d40588e863bf929a083a5dd2ace8fcff77346978a88fba0d97ad56ff759f')],\n",
       " 8092: [('post',\n",
       "   '2569d40588e863bf929a083a5dd2ace8fcff77346978a88fba0d97ad56ff759f')],\n",
       " 8602: [('pre',\n",
       "   '19e41b1b7913b50ba00d2bfccd7d838e60e3cb0ba3066ff1bcb8d099a0e1294a')],\n",
       " 8613: [('pnr',\n",
       "   '19e41b1b7913b50ba00d2bfccd7d838e60e3cb0ba3066ff1bcb8d099a0e1294a')],\n",
       " 8622: [('post',\n",
       "   '19e41b1b7913b50ba00d2bfccd7d838e60e3cb0ba3066ff1bcb8d099a0e1294a')],\n",
       " 8780: [('pre',\n",
       "   'c5abe2ce27fd6c8774881d6f917b791ec86905462b8cd6cf5b18131154ae3c4b')],\n",
       " 8783: [('pnr',\n",
       "   'c5abe2ce27fd6c8774881d6f917b791ec86905462b8cd6cf5b18131154ae3c4b')],\n",
       " 8798: [('post',\n",
       "   'c5abe2ce27fd6c8774881d6f917b791ec86905462b8cd6cf5b18131154ae3c4b')],\n",
       " 8933: [('pre',\n",
       "   'dbb1fad2160c6e08cf2fc6591a3fe0957235abaa116f1680d011a1568b67521c')],\n",
       " 8954: [('pnr',\n",
       "   'dbb1fad2160c6e08cf2fc6591a3fe0957235abaa116f1680d011a1568b67521c')],\n",
       " 8970: [('post',\n",
       "   'dbb1fad2160c6e08cf2fc6591a3fe0957235abaa116f1680d011a1568b67521c')]}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "processed_data['e9be1118-a5cf-4431-b2e8-e3edcfa9f949']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# EXTRACT FRAMES"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 0/150 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 150/150 [00:48<00:00,  3.11it/s]\n",
      "  0%|          | 0/81 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 1\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 81/81 [00:20<00:00,  3.96it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 2\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.18it/s]\n",
      "  0%|          | 0/128 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 128/128 [00:46<00:00,  2.75it/s]\n",
      "  0%|          | 0/3 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 4\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 3/3 [00:00<00:00,  4.06it/s]\n",
      "  0%|          | 0/50 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 5\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 50/50 [00:14<00:00,  3.51it/s]\n",
      "  0%|          | 0/95 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 6\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 95/95 [00:28<00:00,  3.35it/s]\n",
      "  0%|          | 0/100 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 7\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 100/100 [00:37<00:00,  2.70it/s]\n",
      "  0%|          | 0/231 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 8\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 231/231 [01:12<00:00,  3.18it/s]\n",
      "  0%|          | 0/84 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 9\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 84/84 [00:23<00:00,  3.61it/s]\n",
      "  0%|          | 0/121 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 10\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 121/121 [00:40<00:00,  2.97it/s]\n",
      "  0%|          | 0/113 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 11\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 113/113 [00:39<00:00,  2.89it/s]\n",
      "  0%|          | 0/39 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 12\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 39/39 [00:12<00:00,  3.15it/s]\n",
      "  0%|          | 0/127 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 13\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 127/127 [00:35<00:00,  3.53it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 14\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.26it/s]\n",
      "  0%|          | 0/117 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 15\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 117/117 [00:33<00:00,  3.53it/s]\n",
      "  0%|          | 0/57 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 16\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 57/57 [00:18<00:00,  3.15it/s]\n",
      "  0%|          | 0/273 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 17\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 273/273 [01:25<00:00,  3.19it/s]\n",
      "  0%|          | 0/253 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 18\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 253/253 [01:18<00:00,  3.23it/s]\n",
      "  0%|          | 0/83 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 19\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 83/83 [00:26<00:00,  3.12it/s]\n",
      "  0%|          | 0/56 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 20\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 56/56 [00:20<00:00,  2.74it/s]\n",
      "  0%|          | 0/95 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 21\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 95/95 [00:30<00:00,  3.13it/s]\n",
      "  0%|          | 0/3 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 22\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 3/3 [00:01<00:00,  2.17it/s]\n",
      "  0%|          | 0/9 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 23\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 9/9 [00:03<00:00,  2.61it/s]\n",
      "  0%|          | 0/26 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 24\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 26/26 [00:06<00:00,  3.74it/s]\n",
      "  0%|          | 0/252 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 25\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 252/252 [01:01<00:00,  4.09it/s]\n",
      "  0%|          | 0/80 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 26\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 80/80 [00:18<00:00,  4.30it/s]\n",
      "  0%|          | 0/214 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 27\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 214/214 [00:59<00:00,  3.61it/s]\n",
      "  0%|          | 0/62 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 28\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 62/62 [00:17<00:00,  3.46it/s]\n",
      "  0%|          | 0/104 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 29\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 104/104 [00:34<00:00,  2.99it/s]\n",
      "  0%|          | 0/33 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 30\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 33/33 [00:09<00:00,  3.33it/s]\n",
      "  0%|          | 0/54 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 31\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 54/54 [00:18<00:00,  2.90it/s]\n",
      "  0%|          | 0/54 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 32\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 54/54 [00:14<00:00,  3.65it/s]\n",
      "  0%|          | 0/144 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 33\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 144/144 [00:44<00:00,  3.25it/s]\n",
      "  0%|          | 0/154 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 34\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 154/154 [00:34<00:00,  4.52it/s]\n",
      "  0%|          | 0/101 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 35\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 101/101 [00:24<00:00,  4.10it/s]\n",
      "  0%|          | 0/348 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 36\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 348/348 [01:23<00:00,  4.16it/s]\n",
      "  0%|          | 0/609 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 37\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 609/609 [02:31<00:00,  4.02it/s]\n",
      "  0%|          | 0/95 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 38\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 95/95 [00:27<00:00,  3.42it/s]\n",
      "  0%|          | 0/9 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 39\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 9/9 [00:03<00:00,  2.84it/s]\n",
      "  0%|          | 0/133 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 40\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 133/133 [00:45<00:00,  2.93it/s]\n",
      "  0%|          | 0/18 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 41\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:05<00:00,  3.03it/s]\n",
      "  0%|          | 0/246 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 42\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 246/246 [01:12<00:00,  3.40it/s]\n",
      "  0%|          | 0/225 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 43\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 225/225 [01:03<00:00,  3.57it/s]\n",
      "  0%|          | 0/103 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 44\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 103/103 [00:35<00:00,  2.90it/s]\n",
      "  0%|          | 0/104 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 45\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 104/104 [00:39<00:00,  2.64it/s]\n",
      "  0%|          | 0/254 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 46\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 254/254 [01:21<00:00,  3.10it/s]\n",
      "  0%|          | 0/148 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 47\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 148/148 [00:47<00:00,  3.10it/s]\n",
      "  0%|          | 0/30 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 48\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 30/30 [00:08<00:00,  3.36it/s]\n",
      "  0%|          | 0/189 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 49\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 189/189 [00:51<00:00,  3.64it/s]\n",
      "  0%|          | 0/43 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 50\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 43/43 [00:13<00:00,  3.12it/s]\n",
      "  0%|          | 0/18 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 51\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:08<00:00,  2.16it/s]\n",
      "  0%|          | 0/18 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 52\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:09<00:00,  1.92it/s]\n",
      "  0%|          | 0/132 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 53\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 132/132 [00:34<00:00,  3.77it/s]\n",
      "  0%|          | 0/385 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 54\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 385/385 [02:01<00:00,  3.17it/s]\n",
      "  0%|          | 0/163 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 55\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 163/163 [00:52<00:00,  3.12it/s]\n",
      "  0%|          | 0/33 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 56\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 33/33 [00:12<00:00,  2.63it/s]\n",
      "  0%|          | 0/91 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 57\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 91/91 [00:27<00:00,  3.29it/s]\n",
      "  0%|          | 0/107 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 58\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 107/107 [00:27<00:00,  3.87it/s]\n",
      "  0%|          | 0/129 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 59\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 129/129 [00:37<00:00,  3.40it/s]\n",
      "  0%|          | 0/274 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 60\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 274/274 [01:18<00:00,  3.49it/s]\n",
      "  0%|          | 0/36 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 61\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 36/36 [00:12<00:00,  2.92it/s]\n",
      "  0%|          | 0/36 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 62\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 36/36 [00:11<00:00,  3.26it/s]\n",
      "  0%|          | 0/207 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 63\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 207/207 [01:03<00:00,  3.26it/s]\n",
      "  0%|          | 0/148 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 64\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 148/148 [00:50<00:00,  2.91it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 65\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.00it/s]\n",
      "  0%|          | 0/12 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 66\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 12/12 [00:03<00:00,  3.23it/s]\n",
      "  0%|          | 0/217 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 67\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 217/217 [01:02<00:00,  3.48it/s]\n",
      "  0%|          | 0/225 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 68\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 225/225 [01:02<00:00,  3.63it/s]\n",
      "  0%|          | 0/55 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 69\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 55/55 [00:15<00:00,  3.45it/s]\n",
      "  0%|          | 0/99 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 70\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 99/99 [00:36<00:00,  2.70it/s]\n",
      "  0%|          | 0/79 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 71\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 79/79 [00:39<00:00,  1.99it/s]\n",
      "  0%|          | 0/207 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 72\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 207/207 [01:08<00:00,  3.04it/s]\n",
      "  0%|          | 0/141 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 73\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 141/141 [00:43<00:00,  3.23it/s]\n",
      "  0%|          | 0/60 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 74\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 60/60 [00:21<00:00,  2.83it/s]\n",
      "  0%|          | 0/68 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 75\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 68/68 [00:17<00:00,  3.83it/s]\n",
      "  0%|          | 0/51 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 76\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 51/51 [00:21<00:00,  2.33it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 77\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.24it/s]\n",
      "  0%|          | 0/81 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 78\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 81/81 [00:24<00:00,  3.33it/s]\n",
      "  0%|          | 0/30 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 79\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 30/30 [00:10<00:00,  2.85it/s]\n",
      "  0%|          | 0/3 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 80\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 3/3 [00:01<00:00,  2.32it/s]\n",
      "  0%|          | 0/6 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 81\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 6/6 [00:02<00:00,  2.66it/s]\n",
      "  0%|          | 0/15 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 82\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 15/15 [00:05<00:00,  2.58it/s]\n",
      "  0%|          | 0/24 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 83\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 24/24 [00:08<00:00,  2.72it/s]\n",
      "  0%|          | 0/26 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 84\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 26/26 [00:10<00:00,  2.41it/s]\n",
      "  0%|          | 0/29 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 85\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 29/29 [00:10<00:00,  2.68it/s]\n",
      "  0%|          | 0/36 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 86\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 36/36 [00:11<00:00,  3.13it/s]\n",
      "  0%|          | 0/66 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 87\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 66/66 [00:25<00:00,  2.59it/s]\n",
      "  0%|          | 0/309 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 88\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 309/309 [01:35<00:00,  3.25it/s]\n",
      "  0%|          | 0/79 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 89\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 79/79 [00:26<00:00,  2.99it/s]\n",
      "  0%|          | 0/9 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 90\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 9/9 [00:03<00:00,  2.73it/s]\n",
      "  0%|          | 0/64 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 91\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 64/64 [00:24<00:00,  2.59it/s]\n",
      "  0%|          | 0/57 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 92\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 57/57 [00:17<00:00,  3.28it/s]\n",
      "  0%|          | 0/48 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 93\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 48/48 [00:14<00:00,  3.36it/s]\n",
      "  0%|          | 0/67 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 94\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 67/67 [00:22<00:00,  3.04it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 95\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.49it/s]\n",
      "  0%|          | 0/51 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 96\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 51/51 [00:22<00:00,  2.32it/s]\n",
      "  0%|          | 0/60 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 97\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 60/60 [00:25<00:00,  2.32it/s]\n",
      "  0%|          | 0/116 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 98\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 116/116 [00:37<00:00,  3.09it/s]\n",
      "  0%|          | 0/44 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 99\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 44/44 [00:11<00:00,  3.84it/s]\n",
      "  0%|          | 0/15 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 100\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 15/15 [00:03<00:00,  3.77it/s]\n",
      "  0%|          | 0/63 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 101\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 63/63 [00:18<00:00,  3.36it/s]\n",
      "  0%|          | 0/44 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 102\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 44/44 [00:13<00:00,  3.28it/s]\n",
      "  0%|          | 0/51 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 103\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 51/51 [00:13<00:00,  3.78it/s]\n",
      "  0%|          | 0/15 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 104\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 15/15 [00:03<00:00,  3.93it/s]\n",
      "  0%|          | 0/6 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 105\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 6/6 [00:01<00:00,  3.12it/s]\n",
      "  0%|          | 0/92 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 106\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 92/92 [00:29<00:00,  3.09it/s]\n",
      "  0%|          | 0/98 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 107\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 98/98 [00:32<00:00,  3.01it/s]\n",
      "  0%|          | 0/3 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 108\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 3/3 [00:01<00:00,  2.10it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 109\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:05<00:00,  3.99it/s]\n",
      "  0%|          | 0/36 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 110\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 36/36 [00:09<00:00,  3.64it/s]\n",
      "  0%|          | 0/54 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 111\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 54/54 [00:21<00:00,  2.49it/s]\n",
      "  0%|          | 0/3 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 112\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 3/3 [00:00<00:00,  3.58it/s]\n",
      "  0%|          | 0/15 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 113\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 15/15 [00:05<00:00,  2.74it/s]\n",
      "  0%|          | 0/18 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 114\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:04<00:00,  3.76it/s]\n",
      "  0%|          | 0/23 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 115\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 23/23 [00:06<00:00,  3.34it/s]\n",
      "  0%|          | 0/62 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 116\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 62/62 [00:21<00:00,  2.95it/s]\n",
      "  0%|          | 0/51 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 117\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 51/51 [00:16<00:00,  3.04it/s]\n",
      "  0%|          | 0/33 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 118\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 33/33 [00:10<00:00,  3.10it/s]\n",
      "  0%|          | 0/33 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 119\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 33/33 [00:08<00:00,  3.92it/s]\n",
      "  0%|          | 0/12 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 120\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 12/12 [00:04<00:00,  2.89it/s]\n",
      "  0%|          | 0/28 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 121\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 28/28 [00:07<00:00,  3.81it/s]\n",
      "  0%|          | 0/18 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 122\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:05<00:00,  3.25it/s]\n",
      "  0%|          | 0/30 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 123\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 30/30 [00:09<00:00,  3.12it/s]\n",
      "  0%|          | 0/9 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 124\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 9/9 [00:02<00:00,  3.58it/s]\n",
      "  0%|          | 0/6 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 125\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 6/6 [00:02<00:00,  2.66it/s]\n",
      "  0%|          | 0/15 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 126\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 15/15 [00:03<00:00,  4.02it/s]\n",
      "  0%|          | 0/18 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 127\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:06<00:00,  2.77it/s]\n",
      "  0%|          | 0/6 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 128\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 6/6 [00:02<00:00,  2.60it/s]\n",
      "  0%|          | 0/59 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 129\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 59/59 [00:17<00:00,  3.45it/s]\n",
      "  0%|          | 0/45 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 130\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 45/45 [00:13<00:00,  3.27it/s]\n",
      "  0%|          | 0/76 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 131\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 76/76 [00:35<00:00,  2.12it/s]\n",
      "  0%|          | 0/3 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 132\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 3/3 [00:00<00:00,  3.73it/s]\n",
      "  0%|          | 0/9 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 133\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 9/9 [00:02<00:00,  3.36it/s]\n",
      "  0%|          | 0/69 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 134\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 69/69 [00:21<00:00,  3.25it/s]\n",
      "  0%|          | 0/67 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 135\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 67/67 [00:20<00:00,  3.31it/s]\n",
      "  0%|          | 0/12 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 136\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 12/12 [00:05<00:00,  2.28it/s]\n",
      "  0%|          | 0/29 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 137\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 29/29 [00:08<00:00,  3.46it/s]\n",
      "  0%|          | 0/166 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 138\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 166/166 [00:49<00:00,  3.38it/s]\n",
      "  0%|          | 0/66 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 139\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 66/66 [00:19<00:00,  3.37it/s]\n",
      "  0%|          | 0/110 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 140\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 110/110 [00:35<00:00,  3.08it/s]\n",
      "  0%|          | 0/101 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 141\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 101/101 [00:26<00:00,  3.76it/s]\n",
      "  0%|          | 0/161 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 142\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 161/161 [00:49<00:00,  3.24it/s]\n",
      "  0%|          | 0/114 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 143\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 114/114 [00:32<00:00,  3.47it/s]\n",
      "  0%|          | 0/139 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 144\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 139/139 [00:37<00:00,  3.67it/s]\n",
      "  0%|          | 0/59 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 145\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 59/59 [00:17<00:00,  3.35it/s]\n",
      "  0%|          | 0/6 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 146\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 6/6 [00:01<00:00,  3.44it/s]\n",
      "  0%|          | 0/65 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 147\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 65/65 [00:19<00:00,  3.27it/s]\n",
      "  0%|          | 0/27 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 148\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 27/27 [00:10<00:00,  2.58it/s]\n",
      "  0%|          | 0/92 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 149\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 92/92 [00:31<00:00,  2.94it/s]\n",
      "  0%|          | 0/32 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 150\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 32/32 [00:11<00:00,  2.89it/s]\n",
      "  0%|          | 0/30 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 151\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 30/30 [00:11<00:00,  2.58it/s]\n",
      "  0%|          | 0/90 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 152\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 90/90 [00:26<00:00,  3.39it/s]\n",
      "  0%|          | 0/75 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 153\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 75/75 [00:21<00:00,  3.49it/s]\n",
      "  0%|          | 0/51 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 154\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 51/51 [00:14<00:00,  3.61it/s]\n",
      "  0%|          | 0/32 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 155\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 32/32 [00:09<00:00,  3.38it/s]\n",
      "  0%|          | 0/15 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 156\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 15/15 [00:04<00:00,  3.27it/s]\n",
      "  0%|          | 0/42 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 157\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 42/42 [00:12<00:00,  3.36it/s]\n",
      "  0%|          | 0/62 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 158\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 62/62 [00:17<00:00,  3.61it/s]\n",
      "  0%|          | 0/3 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 159\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 3/3 [00:01<00:00,  1.84it/s]\n",
      "  0%|          | 0/41 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 160\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 41/41 [00:13<00:00,  3.01it/s]\n",
      "  0%|          | 0/45 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 161\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 45/45 [00:14<00:00,  3.20it/s]\n",
      "  0%|          | 0/67 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 162\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 67/67 [00:18<00:00,  3.69it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 163\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.39it/s]\n",
      "  0%|          | 0/340 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 164\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 340/340 [01:41<00:00,  3.34it/s]\n",
      "  0%|          | 0/101 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 165\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 101/101 [00:28<00:00,  3.51it/s]\n",
      "  0%|          | 0/24 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 166\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 24/24 [00:07<00:00,  3.29it/s]\n",
      "  0%|          | 0/101 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 167\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 101/101 [00:39<00:00,  2.57it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 168\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.41it/s]\n",
      "  0%|          | 0/168 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 169\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 168/168 [00:51<00:00,  3.27it/s]\n",
      "  0%|          | 0/80 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 170\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 80/80 [00:25<00:00,  3.10it/s]\n",
      "  0%|          | 0/270 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 171\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 270/270 [01:27<00:00,  3.08it/s]\n",
      "  0%|          | 0/113 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 172\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 113/113 [00:32<00:00,  3.44it/s]\n",
      "  0%|          | 0/259 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 173\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 259/259 [01:21<00:00,  3.19it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 174\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.26it/s]\n",
      "  0%|          | 0/163 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 175\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 163/163 [00:49<00:00,  3.28it/s]\n",
      "  0%|          | 0/39 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 176\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 39/39 [00:12<00:00,  3.03it/s]\n",
      "  0%|          | 0/120 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 177\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 120/120 [00:37<00:00,  3.22it/s]\n",
      "  0%|          | 0/300 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 178\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 300/300 [01:07<00:00,  4.42it/s]\n",
      "  0%|          | 0/30 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 179\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 30/30 [00:08<00:00,  3.39it/s]\n",
      "  0%|          | 0/90 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 180\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 90/90 [00:25<00:00,  3.48it/s]\n",
      "  0%|          | 0/9 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 181\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 9/9 [00:02<00:00,  3.28it/s]\n",
      "  0%|          | 0/173 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 182\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 173/173 [00:51<00:00,  3.37it/s]\n",
      "  0%|          | 0/92 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 183\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 92/92 [00:25<00:00,  3.56it/s]\n",
      "  0%|          | 0/12 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 184\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 12/12 [00:04<00:00,  2.69it/s]\n",
      "  0%|          | 0/66 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 185\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 66/66 [00:18<00:00,  3.52it/s]\n",
      "  0%|          | 0/144 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 186\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 144/144 [00:43<00:00,  3.30it/s]\n",
      "  0%|          | 0/84 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 187\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 84/84 [00:26<00:00,  3.21it/s]\n",
      "  0%|          | 0/41 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 188\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 41/41 [00:11<00:00,  3.47it/s]\n",
      "  0%|          | 0/80 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 189\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 80/80 [00:26<00:00,  3.07it/s]\n",
      "  0%|          | 0/48 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 190\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 48/48 [00:15<00:00,  3.10it/s]\n",
      "  0%|          | 0/99 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 191\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 99/99 [00:32<00:00,  3.04it/s]\n",
      "  0%|          | 0/453 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 192\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 453/453 [02:41<00:00,  2.80it/s]\n",
      "  0%|          | 0/57 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 193\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 57/57 [00:18<00:00,  3.10it/s]\n",
      "  0%|          | 0/77 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 194\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 77/77 [00:27<00:00,  2.77it/s]\n",
      "  0%|          | 0/27 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 195\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 27/27 [00:07<00:00,  3.77it/s]\n",
      "  0%|          | 0/33 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 196\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 33/33 [00:08<00:00,  3.67it/s]\n",
      "  0%|          | 0/32 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 197\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 32/32 [00:10<00:00,  3.03it/s]\n",
      "  0%|          | 0/132 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 198\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 132/132 [00:44<00:00,  3.00it/s]\n",
      "  0%|          | 0/38 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 199\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 38/38 [00:13<00:00,  2.90it/s]\n",
      "  0%|          | 0/33 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 200\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 33/33 [00:10<00:00,  3.12it/s]\n",
      "  0%|          | 0/5 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 201\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 5/5 [00:01<00:00,  3.73it/s]\n",
      "  0%|          | 0/90 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 202\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 90/90 [00:25<00:00,  3.56it/s]\n",
      "  0%|          | 0/15 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 203\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 15/15 [00:04<00:00,  3.18it/s]\n",
      "  0%|          | 0/44 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 204\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 44/44 [00:13<00:00,  3.23it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 205\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.25it/s]\n",
      "  0%|          | 0/18 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 206\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:04<00:00,  3.75it/s]\n",
      "  0%|          | 0/45 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 207\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 45/45 [00:16<00:00,  2.78it/s]\n",
      "  0%|          | 0/147 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 208\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 147/147 [00:51<00:00,  2.88it/s]\n",
      "  0%|          | 0/93 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 209\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 93/93 [00:23<00:00,  4.02it/s]\n",
      "  0%|          | 0/56 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 210\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 56/56 [00:15<00:00,  3.64it/s]\n",
      "  0%|          | 0/18 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 211\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:05<00:00,  3.28it/s]\n",
      "  0%|          | 0/94 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 212\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 94/94 [00:24<00:00,  3.77it/s]\n",
      "  0%|          | 0/15 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 213\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 15/15 [00:03<00:00,  3.83it/s]\n",
      "  0%|          | 0/127 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 214\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 127/127 [00:36<00:00,  3.50it/s]\n",
      "  0%|          | 0/105 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 215\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 105/105 [00:31<00:00,  3.32it/s]\n",
      "  0%|          | 0/18 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 216\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:04<00:00,  4.06it/s]\n",
      "  0%|          | 0/9 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 217\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 9/9 [00:02<00:00,  4.15it/s]\n",
      "  0%|          | 0/30 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 218\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 30/30 [00:10<00:00,  2.95it/s]\n",
      "  0%|          | 0/21 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 219\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 21/21 [00:06<00:00,  3.32it/s]\n",
      "  0%|          | 0/80 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing clip 220\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 80/80 [00:27<00:00,  2.86it/s]\n"
     ]
    }
   ],
   "source": [
    "import cv2\n",
    "import os\n",
    "from tqdm import tqdm\n",
    "\n",
    "def extract_frames(video_folder, output_folder, data):\n",
    "    \"\"\"\n",
    "    Extracts frames from clip files based on provided data and saves them. Iterates through each video clip\n",
    "    identified by clip_uid and extracts frames specified in the `data` parameter.\n",
    "    \n",
    "    Args:\n",
    "    - video_folder (str): Path to the folder containing the Ego4D clips.\n",
    "    - output_folder (str): Path to the folder where extracted frames will be saved.\n",
    "    - data (dict): A dictionary retrieved with process_json_files() function.\n",
    "    \"\"\"\n",
    "    CNT_CLIP = 0\n",
    "    for clip_uid, frames_data in data.items():\n",
    "        print('Processing clip {}'.format(CNT_CLIP))\n",
    "        CNT_CLIP+=1\n",
    "        video_path = os.path.join(video_folder, f\"{clip_uid}.mp4\")\n",
    "        cap = cv2.VideoCapture(video_path)\n",
    "\n",
    "        if not cap.isOpened():\n",
    "            print(f\"Error: Couldn't open the video file {video_path}\")\n",
    "            continue\n",
    "\n",
    "        for frame_number, annotations in tqdm(frames_data.items()):\n",
    "            cap.set(cv2.CAP_PROP_POS_FRAMES, frame_number - 1)  # setting the frame position\n",
    "\n",
    "            ret, frame = cap.read()\n",
    "            if ret:\n",
    "                for frame_type, annot_uid in annotations:\n",
    "                    output_path = os.path.join(output_folder, annot_uid, f\"{clip_uid}_{frame_type}.jpg\")\n",
    "                    os.makedirs(os.path.dirname(output_path), exist_ok=True)\n",
    "                    cv2.imwrite(output_path, frame)\n",
    "            else:\n",
    "                print(f\"Error: Couldn't read frame {frame_number} from video {video_path}\")\n",
    "\n",
    "        cap.release()\n",
    "\n",
    "# Modify these paths\n",
    "video_folder = ...\n",
    "output_folder = \"frames_all\"\n",
    "\n",
    "extract_frames(video_folder, output_folder, processed_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6250"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(os.listdir('frames_all'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ADD BOTH HANDS BBOX"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "\n",
    "def compute_union_bbox(bbox1, bbox2):\n",
    "    \"\"\"\n",
    "    Computes union of 2 bboxes, used for both_hands\n",
    "    \"\"\"\n",
    "    x_min = min(bbox1['x'], bbox2['x'])\n",
    "    y_min = min(bbox1['y'], bbox2['y'])\n",
    "    \n",
    "    x_max = max(bbox1['x'] + bbox1['width'], bbox2['x'] + bbox2['width'])\n",
    "    y_max = max(bbox1['y'] + bbox1['height'], bbox2['y'] + bbox2['height'])\n",
    "    \n",
    "    return {\n",
    "        'x': x_min,\n",
    "        'y': y_min,\n",
    "        'width': x_max - x_min,\n",
    "        'height': y_max - y_min\n",
    "    }\n",
    "\n",
    "def add_union_bbox(data):\n",
    "    \"\"\"\n",
    "    Adds both_hands bounding box to the annotation\n",
    "    \"\"\"\n",
    "    for key in ['pre_frame', 'pnr_frame', 'post_frame']:\n",
    "        left_hand = None\n",
    "        right_hand = None\n",
    "        for annotation in data[key]['bbox']:\n",
    "            if annotation['object_type'] == 'left_hand':\n",
    "                left_hand = annotation['bbox']\n",
    "            elif annotation['object_type'] == 'right_hand':\n",
    "                right_hand = annotation['bbox']\n",
    "        \n",
    "        if left_hand and right_hand:\n",
    "            union_bbox = compute_union_bbox(left_hand, right_hand)\n",
    "        elif left_hand:\n",
    "            union_bbox = left_hand\n",
    "        elif right_hand:\n",
    "            union_bbox = right_hand\n",
    "        else:\n",
    "            continue\n",
    "        \n",
    "        data[key]['bbox'].append({\n",
    "            \"object_type\": \"both_hands\",\n",
    "            \"structured_noun\": None,\n",
    "            \"instance_number\": 1,\n",
    "            \"bbox\": union_bbox\n",
    "        })\n",
    "\n",
    "    return data\n",
    "\n",
    "def read_json(filename):\n",
    "    with open(filename, 'r') as file:\n",
    "        data = json.load(file)\n",
    "    return data\n",
    "\n",
    "def write_json(filename, data):\n",
    "    with open(filename, 'w') as file:\n",
    "        json.dump(data, file, indent=4)\n",
    "\n",
    "def modify_json_files(root_folder):\n",
    "    \"\"\"\n",
    "    Function to enrich the existing annotations with both_hands bounding boxes\n",
    "    \"\"\"\n",
    "    for subdir, _, files in os.walk(root_folder):\n",
    "        for file in files:\n",
    "            if file.endswith(\".json\"):\n",
    "                file_path = os.path.join(subdir, file)\n",
    "                \n",
    "                # Reading the JSON file\n",
    "                with open(file_path, 'r') as json_file:\n",
    "                    data = json.load(json_file)\n",
    "                \n",
    "                # Modifying the data with your function\n",
    "                add_union_bbox(data)\n",
    "                \n",
    "                # Writing the modified data back to the file\n",
    "                with open(file_path, 'w') as json_file:\n",
    "                    json.dump(data, json_file, indent=4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "modify_json_files('annotations_all')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CREATE MANIFEST\n",
    "\n",
    "Creating the list of data objects to be annotated"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total number of SG: 6250\n"
     ]
    }
   ],
   "source": [
    "JOB_NAME = 'jobs_all'\n",
    "MANIFEST_NAME = '_unict_all.manifest'\n",
    "BUCKET_NAME = ...\n",
    "ANNOTS_PATH = 'annotations_all'\n",
    "\n",
    "folders = os.listdir('frames_all')\n",
    "ls_manifest = []\n",
    "k = \"source-ref\"\n",
    "try_id = 1\n",
    "for annot_uid in folders:\n",
    "    v = \"s3://{}/data/jobs/{}/{}/{}-sequence-{}.json\".format(BUCKET_NAME, JOB_NAME, annot_uid, annot_uid, try_id)\n",
    "    ls_manifest.append({k:v})\n",
    "cnt = 0\n",
    "with open(MANIFEST_NAME, 'w') as f:\n",
    "    for item in ls_manifest:\n",
    "        json.dump(item, f)\n",
    "        f.write('\\n')\n",
    "        cnt+=1\n",
    "print('Total number of SG: {}'.format(cnt))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CREATE JOBS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "for ii, annot_id in enumerate(folders):\n",
    "    file_list = os.listdir(os.path.join(ANNOTS_PATH, annot_id))\n",
    "    clip_id = os.path.basename([file for file in file_list if file.endswith('.json')][0])\n",
    "    data = {\"seq-no\":ii+1,\n",
    "           \"prefix\":\"s3://{}/data/jobs/{}/{}/\".format(BUCKET_NAME, JOB_NAME,annot_id),\n",
    "           \"number-of-frames\":3,\n",
    "           \"frames\":[{\"frame-no\":0,\"frame\":\"{}_pnr.jpg\".format(clip_id[:-5])},\n",
    "            {\"frame-no\":1,\"frame\":\"{}_post.jpg\".format(clip_id[:-5])},\n",
    "            {\"frame-no\":2,\"frame\":\"{}_pre.jpg\".format(clip_id[:-5])}]}\n",
    "    os.makedirs('{}/{}'.format(JOB_PATH,annot_id), exist_ok=True)\n",
    "    file_to_save = '{}/{}/{}-sequence-{}.json'.format(JOB_PATH, annot_id, annot_id, try_id)\n",
    "    with open(file_to_save, 'w') as f:\n",
    "        json.dump(data, f)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Create Narration-Annotation mapping"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6250\n"
     ]
    }
   ],
   "source": [
    "mappings = []\n",
    "for folder in os.listdir('annotations_all'):\n",
    "    for file in os.listdir(os.path.join('annotations_all',folder)):\n",
    "        if file.endswith('.json'):\n",
    "            pf = os.path.join('annotations_all',folder,file)\n",
    "            with open(pf,'r') as pf_json:\n",
    "                cont = json.load(pf_json)['narrations_infos'][0]\n",
    "            mappings.append({folder:cont})\n",
    "print(len(mappings))\n",
    "narr_annot_mapping_new = {'mappings': mappings}\n",
    "with open('narration_annotation_mappings_unict_all.json', 'w') as outfile:\n",
    "    json.dump(narr_annot_mapping_new, outfile)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
